home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / BORUSR2.ZIP;1 / COLORCTL.TXT < prev    next >
Encoding:
Text File  |  1992-06-12  |  9.1 KB  |  206 lines

  1. ================================================================================
  2. COLORCTL.TXT -- first, the text of the article in TechNotes (January, 1992)
  3. by the author of these programs (George E. McMullen), and then a brief 
  4. description of the way they are used in the BORUSER system on the BORLAND BBS 
  5. (BORBBS). If you examine the actual code (at the beginning) there are 
  6. descriptions of the changes I made (minor) in the programs.
  7. (Ken Mayer, 06/12/1992)
  8. ================================================================================
  9.  
  10. Eye Candy
  11. George E. McMullen
  12.  
  13. More colors than you can shake a paintbrush at
  14.  
  15. In today's ever increasing GUI (Graphical User Interface) world, applications 
  16. that rely on DOS default colors seem rather archaic.  As technology increases, 
  17. so does the customer's expectations when purchasing a product or hiring a 
  18. consultant.
  19.  
  20. dBASE IV produces rather nice displays via screen saves and moving windows.  
  21. It also gives you a decent assortment of colors to work with.  But as we all 
  22. know, there are thousands of shades and I thought that it was worthwhile to 
  23. increase the the number of colors available in your dBASE IV applications.  
  24. For instance, of all the many colors available on a VGA monitor, there is 
  25. only a concise number of colors available to the dBASE programmerÆ’or so it 
  26. would seem.  You see, although dBASE IV provides only a limited number of color 
  27. options, it also provides the interface for enhancing those colors and other
  28. options.
  29.  
  30. The .BIN Interface
  31.  
  32. One of the lesser used commands by developers, the LOAD command happens to be 
  33. one of the most powerful commands in dBASE IV.  Basically, the LOAD command 
  34. places a binary (.BIN) file in memory where it can be accessed programatically 
  35. using the complimentary CALL command.  This .BIN interface allows dBASE IV the 
  36. ability to communicate with the outside world.  Once a link is achieved, 
  37. dBASE IV can take control and direct streams of data producing unlimited 
  38. capabilities.  In an attempt to capitalize on this, companies have developed a 
  39. mulitude of products for interfacing with hand scanners, lightbar readers, 
  40. communication packages and graphical interfaces.
  41.  
  42. ColorCtl.BIN (available from our BBS in the file COLORCTL.ZIP) provides 
  43. dBASE IV with an interface for controlling DOS color settings.  With this 
  44. program, you can make changes to any one of 16 color settings by controlling 
  45. the red, green and blue gun intensity values.  The range of each color gun 
  46. value is 0 - 63, which translates to over 260,000 possible color settings.  
  47. The syntax to control color hues is:
  48.  
  49. CALL ColorCtl WITH "/SET", "INDEX=x", "RED=n", "GREEN=n", "BLUE=n"
  50.  
  51. where x and n are numerical values between 0-15 and 0-63 respectively
  52. (see table below).
  53.  
  54. Option: Range:  Description:
  55.  
  56. INDEX = 0 - 15  DOS color index number
  57. RED   = 0 - 63  Red gun value
  58. GREEN = 0 - 63  Green gun value
  59. BLUE  = 0 - 63  Blue gun value
  60. DELAY = 0 - 99  Delay factor
  61.  
  62. In addition, you can progressively change any one of 16 colors into another 
  63. color value producing a "fading effect."  This command also allows a delay 
  64. factor for increased control.  The syntax goes as follows:
  65.  
  66. CALL ColorCtl WITH "/FADE", "INDEX=x","RED=n", "GREEN=n", "BLUE=n", "DELAY=n"
  67.  
  68. Finally, you can reset one or all DOS colors back to factory settings using 
  69. the syntax:
  70.  
  71. CALL ColorCtl WITH "/RESET"
  72. CALL colorctl WITH "/RESET", "INDEX=x"
  73.  
  74. Inside ColorCtl.BIN
  75.  
  76. This code is an extract from a VGA 256 color control program that I wrote which
  77. was then converted to a .BIN file.  Purists will please forgive me if the code
  78. isn't squeaky clean; it's the concept that's being emphasized here.
  79.  
  80. The main fuctionality of ColorCtl.BIN comes from the Interrupt 10H BIOS service.
  81. The functions zSetAnalogHue and zReadAnalogHue use this service for setting and
  82. reading DOS color settings. 
  83.  
  84. Interupt 10H:  VGA BIOS Services
  85.  
  86. SET COLOR SERVICE:
  87.   AH = 10H
  88.   AL = 10H  Set one color register
  89.   BX = Color register to set (see DOS's translation table below)
  90.   DH = Red value
  91.   CH = Green value
  92.   CL = Blue value
  93. READ COLOR SERVICE:
  94.   AH = 10H
  95.   AL = 15H Read one color register
  96.   BX = Color register to read (see DOS's translation table below)
  97. RETURNS:
  98.   DH = Red value
  99.   CH = Green value
  100.   CL = Blue value
  101.  
  102. TRANSLATION TABLE: (COLORCTL.BIN Index Number/dBASE Color Codes)
  103.  
  104. Index Number:   0 1 2 3  4 5  6  7 8  9  10 11  12  13  14  15
  105. dBASE Color:    N B G GB R RB GR W N+ B+ G+ GB+ R+  RB+ GR+ W+
  106.  
  107. *** The code for the C program to create the .BIN file and the (dBASE) programs
  108. *** SETCLR.PRG and CDEFAULT.PRG have been removed from here. You can download
  109. *** the original programs from the BORBBS by downloading the file:
  110. *** COLORCTL.ZIP, you can get the complete article (with the 'C' code attached)
  111. *** by downloading the file: TNDB0192.ZIP from the BORBBS, which contains the
  112. *** complete text of the issue of TechNotes that this article is from.
  113.  
  114. --------------------------------------------------------------------------------
  115. END OF TECHNOTES ARTICLE -- On to Ken Mayer's Notes (a simpler explanation of
  116. what is happening ...)
  117. --------------------------------------------------------------------------------
  118.  
  119. ------------
  120. COLORCTL.BIN
  121. ------------
  122.  
  123. This file is a binary file, that can be used with dBASE (and probably other
  124. software as well), to change the color values of the actual colors used
  125. by the software (on a VGA monitor). What does this mean? It means that if, for 
  126. example, you do not like the color of BLUE associated with the color 'B' in 
  127. dBASE, you can change the values on a VGA monitor -- by actually changing how
  128. much color from each 'gun' in the monitor is sent to the monitor. There are 
  129. three guns, RED, GREEN, and BLUE. By changing the values from these, you can 
  130. get at least 256 shades of any color. Taking all three 'guns' to 0 will give 
  131. you black ('N' in dBASE). Taking all three guns up to their maximum value 
  132. (63) will give you white ('bright white' or 'W+' in dBASE).
  133.  
  134. ------------
  135. CDEFAULT.PRG
  136. ------------
  137.  
  138. This program loads the COLORCTL.BIN file into memory so it can be used, and
  139. then loads the 'current settings' in the file: CLRDESC.MEM. This file contains
  140. the 'current' settings of the guns. This information is loaded into an array, 
  141. and then set via a loop using the COLORCTL.BIN file. The current settings are 
  142. ones that I defined for this system. The actual system defaults can be 
  143. restored/saved to CLRDESC.MEM via the SETCLR.PRG program. My original settings 
  144. are in CLRDESC.FIL and are copied to the file CLRDESC.MEM by the menu program 
  145. when you first run it, or the CONFIG.PRG program if you decide to change to VGA. 
  146. These are my settings only. (Basically I altered the dark blue a bit to make it 
  147. darker, and RED, CYAN and YELLOW to make them more vibrant ...)
  148.  
  149. NOTE: the original programs used COLOR.MEM for this. I was already using a mem
  150. file called COLOR.MEM, which is why I renamed it to CLRDESC.MEM.
  151.  
  152. ----------
  153. SETCLR.PRG
  154. ----------
  155.  
  156. This is the program that is called when you tell the ATUSER system that you want
  157. to modify the VGA Color Values. This program is confusing to the first time 
  158. user. There are a lot of things going on on the screen. 
  159.  
  160. THE SCREEN
  161. First, the program is showing the 16 colors you can use in dBASE via the
  162. SET COLOR [OF <area group>] TO <colors> commands (see the Language Reference,
  163. under SET COLOR for more information).  This is the color bar you see across
  164. the top portion of the screen. In the middle is a box showing the 'current'
  165. color you are modifying, and the values from each 'gun' assigned currently to
  166. that color. The rest of the screen is information (some of which I added to the
  167. original program).
  168.  
  169. LOAD OLD COLORS
  170. You can load the colors in the CLRDESC.MEM file by pressing the keystroke:
  171. <Ctrl><Home>. This will load the current settings. If you do not choose to do
  172. this, you get the default settings for dBASE (and the PC in general).
  173.  
  174. CHANGING COLORS
  175. Using the left and right arrow keys allows you to select the actual color(s)
  176. to modify (signified by the box in the middle of the screen). 
  177.  
  178. To alter the color(s), use the <Home> and <End> keys to raise/lower the values
  179. of the RED gun; the Up/Down arrows to raise/lower the values of the GREEN gun;
  180. and the <PgUp>/<PgDn> keys to raise/lower the values of the BLUE gun.
  181.  
  182. These combinations will change each color, producing some interesting effects.
  183.  
  184. (As a side note, the only colors I'm using in the system are:
  185.   Black        (N)
  186.   Bright White (W+)
  187.   Yellow       (RG+)
  188.   Red          (R)
  189.   Cyan         (GB)
  190.   Blue         (B)
  191. Just so that you know ... altering other colors won't really affect anything for
  192. this system.)
  193.  
  194. SAVING COLORS
  195. You can save the colors you have changed by pressing: <Ctrl><End>
  196.  
  197. EXIT
  198. Exiting this program is as simple as pressing the <Escape> key, however,
  199. if you have changed things, the program does NOT save, and does NOT ask if
  200. you WANT to save. (Handy, however, if you did something weird, and don't
  201. want to save it ...)
  202.  
  203. --------------------------------------------------------------------------------
  204. END OF FILE: COLORCTL.TXT
  205. --------------------------------------------------------------------------------
  206.